<template>
  <div class="right-in-box">
    <div class="right-in-box-header">
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="Component" name="assembly"></el-tab-pane>
        <!--        <el-tab-pane label="样式" name="style"></el-tab-pane>-->
        <!--        <el-tab-pane label="设置" name="setting"></el-tab-pane>-->
      </el-tabs>
    </div>
    <div class="right-in-box-footer" :style="{height: (tableHeight-76)+'px'}">
      <el-tabs v-model="activeNames">
        <el-tab-pane :label="item.name" :name="index.toString()" v-for="(item,index) in planetChartData" :key="index"></el-tab-pane>
      </el-tabs>
      <div class="components-box">
        <div class="components-box-list" v-for="(item,index) in planetChartData[activeNames].list"
             @click="getCompontentsFn(item)">
          <div class="components-box-list-in" :class="{active:activeTab==item.compontents}">
            <p>{{ item.name }}</p>
            <div class="planetChart-box">
              <component :is="item.compontents" inPage="compontents"></component>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import planetChartData from './componentsData'

export default {
  name: "right-data",
  props: ['tableHeight', 'detailType'],
  data() {
    return {
      activeName: 'assembly',
      activeNames: '0',
      planetChartData: planetChartData,
      activeTab: '',
    }
  },
  watch: {
    activeTab() {
      this.$emit('changeCompontents', `${this.activeNames}-${this.activeTab}`)
    },
    detailType() {
      if (this.detailType) {
        // console.log('detailType=====>', this.detailType.split('-'))
        let a_ = this.detailType.split('-')
        this.activeNames = a_[0]
        this.activeTab = a_[1]
      }
    }
  },
  methods: {
    getCompontentsFn(item) {
      this.activeTab = item.compontents
    }
  }
}
</script>

<style scoped>
.right-in-box {
  padding: 10px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.right-in-box-footer {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.components-box {
  overflow-y: auto;
  flex: 1;
}

.components-box-list {
  float: left;
  width: 50%;
  margin-bottom: 10px;
  padding: 0 5px;
  box-sizing: border-box;

}

.components-box-list-in {
  border: 1px solid #dcdfe6;
  cursor: pointer;
  border-radius: 3px;
}

.components-box-list-in.active {
  border: 1px solid #36a3f7;
  box-shadow: 0 0 2px #36a3f7;
}

.components-box-list-in:hover {
  box-shadow: 0 0 2px #36a3f7;
}

.components-box-list-in p {
  text-align: center;
  font-weight: 700;
  height: 40px;
  line-height: 40px;
  color: #909399;
  border-bottom: 1px solid #efefef;
  padding: 0;
  margin: 0;
}

.planetChart-box {
  height: 190px;
}
</style>
<!--<div class="components-box">-->
<!--<div class="components-box-list" v-for="item in 10">-->
<!--  <p>{{item}}</p>-->
<!--</div>-->
<!--</div>-->
